package com.itcam.cammybibackend.utils;

import com.itcam.cammybibackend.model.entity.User;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.DigestUtils;

/**
 * SQL 工具
 *
 */
public class SqlUtils {

    /**
     * 校验排序字段是否合法（防止 SQL 注入）
     *
     * @param sortField
     * @return
     */
    public static boolean validSortField(String sortField) {
        if (StringUtils.isBlank(sortField)) {
            return false;
        }
        return !StringUtils.containsAny(sortField, "=", "(", ")", " ");
    }

    public static void main(String[] args) {
        String encryptPassword = DigestUtils.md5DigestAsHex(("cammy" + "158633115").getBytes());

        System.out.println("result = " + encryptPassword);
    }
}
